﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

namespace WAF.EntityFramework
{
    /// <summary>
    /// 实体类基类，请重写需要的虚方法已实现实体自身业务逻辑
    /// </summary>
    public abstract class Entity
    {
        /// <summary>
        /// 实体类的ID字段
        /// </summary>
        [EntityField(0, isDisplay: true, isPrimaryKey: true, dbType: DbType.Int64, label: "ID")]
        public long Id { get; set; }

        /// <summary>
        /// 数据自定义验证操作
        /// </summary>
        public virtual void Validate() { }

        /// <summary>
        /// 插入记录之前的操作
        /// </summary>
        public virtual void BeforeInsert() { }

        /// <summary>
        /// 插入记录之后的操作
        /// </summary>
        public virtual void AfterInsert() { }

        /// <summary>
        /// 更新记录之前的操作
        /// </summary>
        public virtual void BeforeUpdate() { }

        /// <summary>
        /// 更新记录之后的操作
        /// </summary>
        public virtual void AfterUpdate() { }

        /// <summary>
        /// 删除记录之前的操作
        /// </summary>
        public virtual void BeforeDelete() { }

        /// <summary>
        /// 删除记录之后的操作
        /// </summary>
        public virtual void AfterDelete() { }
    }
}
